import { Component, OnInit } from '@angular/core';
import {FormBuilder, FormGroup, Validators} from "@angular/forms";

@Component({
  selector: 'app-register',
  templateUrl: './register.component.html',
  styleUrls: ['./register.component.scss']
})
export class RegisterComponent implements OnInit {
  items: string[];
  form: FormGroup;
  private readonly avatarName = 'avatars'
  constructor(private fb: FormBuilder) { }

  ngOnInit() {
    // 随机选
    // const img = `${this.avatarName}:svg-${Math.floor(Math.random() * 16).toFixed(0)}`
    const nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];
    this.items = nums.map(num => `avatars:svg-${num}`);
    this.form = this.fb.group({
      email: [''],
      name: [],
      password: [],
      repeat: [],
      avatar: ['', Validators.required]
    })
  }
  onSubmit(form) {
    console.log(form)
  }

}
